package com.globallogic.learning.kozius.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * Class contains information about an examination related to a lesson if it is applicable according to curriculum
 * <p/>
 * Created by sergii.koziumynskyi on 2/4/14.
 */
public final class Examination {
    public Examination(String name, List<Ticket> tickets) {
        this.name = name;
        this.tickets = tickets;
    }

    public Examination(String name) {
        this.name = name;
    }

    public Examination() {
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Ticket> getTickets() {
        return tickets;
    }

    public void setTickets(List<Ticket> tickets) {
        this.tickets = tickets;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Examination that = (Examination) o;

        if (id != that.id) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (tickets != null ? !tickets.equals(that.tickets) : that.tickets != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (tickets != null ? tickets.hashCode() : 0);
        result = 31 * result + id;
        return result;
    }

    @Override
    public String toString() {
        return "Examination{" +
                "name='" + name + '\'' +
                ", tickets=" + tickets +
                ", id=" + id +
                '}';
    }

    private String name = "";
    private List<Ticket> tickets = new ArrayList<Ticket>();

    private int id;
    private static int nextId = 610000000; // 61 prefix will show that it is an examination

    {
        id = nextId;
        nextId++;
    }

}
